<?php
/**
 * Created by PhpStorm.
 * User: yu
 * Date: 2017/8/6
 * Time: 下午5:39
 */

namespace app\api\validate;


use app\lib\exception\ParamException;
use think\Request;
use think\Validate;

class BaseValidate extends Validate
{
	public function goCheck(){
		//1.获取http请求参数
		$params = Request::instance()->param();
		//2. 执行校验
		$result = $this->check($params);
		//3. 抛出异常或通过
		if(!$result){
			$e = new ParamException();
			$e->msg = $this->error;
			throw $e;

//			$error = $this->error;
//			throw new Exception($error);

		}else{
			return true;
		}
	}
}